package com.wisemoresystem.seal.util.abchinaFinger;

import org.ne.framework.data.util.ChkTools;

import com.wisemoresystem.seal.util.abchinaFinger.cics.CoreTrans;
import com.wisemoresystem.seal.util.abchinaFinger.common.AbcCoreCfg;
import com.wisemoresystem.seal.util.abchinaFinger.test.TestUsapTrans;

public class FingerTools {

	public static boolean login(String code, String feture,
			String product_info, String bank_code) {
		String abc_type = new AbcCoreCfg(null).getAbc_type();

		if (ChkTools.isNull(code) || code.length() != 9) {
			return false;
		}
		code = boeingToCode(code, bank_code);

		System.err.println("进入指纹登录:");
		System.err.println("code->" + code);
		System.err.println("feture->" + feture);
		System.err.println("product_info->" + product_info);

		try {
			if ("cics".equals(abc_type)) {
				// code = "0400100010";
				// feture =
				// "BR9FsRYLARIuDwHQGw8CxSIUAcYMFYJhGBUBA0MeAuolHwLJNyAC2wcnAqUdKAK8KioBGTEsAtQ3LQInJC8BGT8yAdYnNgHNBziCV0k9AvIfPgK6C0ABohpAgmY6QAHbNkECJUpDAeMcRgG0R0gB30lMAvMxVALcFmSCZSdlAssAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
				// product_info = "TECHSHINO";

				CoreTrans ct = new CoreTrans();
				String result = ct.fingerCheck(code, feture, product_info);
				System.err.println("CICS登录校验：" + result);
				return result.startsWith("SUCCESS.") ? true : false;
			} else if ("usap".equals(abc_type)) {

				// code = "0400100010";
				// feture =
				// "BR9FsRYLARIuDwHQGw8CxSIUAcYMFYJhGBUBA0MeAuolHwLJNyAC2wcnAqUdKAK8KioBGTEsAtQ3LQInJC8BGT8yAdYnNgHNBziCV0k9AvIfPgK6C0ABohpAgmY6QAHbNkECJUpDAeMcRgG0R0gB30lMAvMxVALcFmSCZSdlAssAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
				// product_info = "MIAXIS";

				String result = TestUsapTrans
						.finger(code, feture, product_info);
				System.err.println("USAP登录校验：" + result);
				return result.startsWith("SUCCESS.") ? true : false;
			} else {
				throw new RuntimeException(
						"AbcCore.properties  ABC.type配置有问题.参考注释.");
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

	}

	// boeing 账号转账号
	private static String boeingToCode(String code, String bank_code) {
		return code.substring(0, 2)
				+ bank_code.substring(bank_code.length() - 4)
				+ code.substring(5);
	}

	public static void main(String[] args) {
		System.err.println(boeingToCode("040001234", "1234567890"));
	}
}
